package com.hefu.virtuallife.ui;

import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.hefu.virtuallife.R;
import com.hefu.virtuallife.utils.GlideUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

public class BgActivity extends AppCompatActivity {

    @BindView(R.id.bg_image)
    ImageView bg_image;
    @BindView(R.id.img_back)
    ImageView back_btn;
    @BindView(R.id.title)
    TextView title;

    @Override
        protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bg);
        initFullScreen();
        ButterKnife.bind(this);

        String text = getIntent().getStringExtra("title");
        title.setText(text);

        back_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        int resId = getIntent().getIntExtra("bg", 0);
        if (resId == 0){
            return;
        }
        GlideUtils.load(bg_image, resId);
    }

    public void initFullScreen() {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN);
        getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int visibility) {
                getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN);
            }
        });
        Window window = getWindow();
        int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
        //设置当前窗体为全屏显示
        window.setFlags(flag, flag);
    }
}
